package org.jetlinks.pro.koudai.web;


import io.swagger.v3.oas.annotations.tags.Tag;
import org.hswebframework.web.authorization.annotation.Resource;
import org.jetlinks.pro.koudai.Services.ExperimentService;
import org.jetlinks.pro.koudai.entity.ExperimentEntity;
import org.jetlinks.pro.koudai.tenant.KoudaiAssetType;
import org.jetlinks.pro.tenant.AssetType;
import org.jetlinks.pro.tenant.crud.TenantCorrelatesAccessCrudController;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Nonnull;
import java.util.function.Function;

@RestController
@RequestMapping("/experiment")
@Resource(id = "experiment-manager", name = "实验管理")
@Tag(name = "实验管理")
public class ExperimentController implements TenantCorrelatesAccessCrudController<ExperimentEntity, String> {

    private final ExperimentService experimentService;

    public ExperimentController(ExperimentService experimentService) {
        this.experimentService = experimentService;
    }


    @Override
    public ExperimentService getService() {
        return experimentService;
    }

    @Nonnull
    @Override
    public AssetType getAssetType() {
        return KoudaiAssetType.experiment;
    }

    @Nonnull
    @Override
    public Function<ExperimentEntity, ?> getAssetIdMapper() {
        return ExperimentEntity::getId;
    }

    @Nonnull
    @Override
    public String getAssetProperty() {
        return "experiment";
    }
}
